package com.muyu.controller;

import com.muyu.entity.UserEntity;
import com.muyu.group.AddGroup;
import com.muyu.group.UpdateGroup;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: UpgradeUserController
 * @Author: Zirun.Xin
 * @Date: 2025/4/7 下午4:56
 * @Version: 1.0
 * @Description: 升级版用户控制层
 */
@Slf4j
@RestController
@RequestMapping(value = "/api/v1/upgrade-user")
public class UpgradeUserController {

    /**
     * 用户添加
     * @param userEntity 用户实体
     * @param bindingResult 绑定结果集
     * @return 响应结果集
     */
    @PostMapping(value = "/save")
    public Map<String, String> saveUser(@Validated(value = AddGroup.class) @RequestBody UserEntity userEntity,
                                        BindingResult bindingResult) {
        log.info("{}", userEntity);
        return null;
    }

    /**
     * 用户修改
     * @param userEntity 用户实体
     * @param bindingResult 绑定结果集
     * @return 响应结果集
     */
    @PostMapping(value = "/update")
    public Map<String, String> updateUser(@Validated(value = UpdateGroup.class) @RequestBody UserEntity userEntity,
                                          BindingResult bindingResult) {
        log.info("{}", userEntity);
        return null;
    }
}
